//
//  JournalURLRequst.m
//  BSLCar
//
//  Created by 梁毅 on 15/6/1.
//  Copyright (c) 2015年 lyz. All rights reserved.
//

#import "JournalURLRequst.h"

@implementation JournalURLRequst
+(NSArray *)getParserResult
{
    NSMutableArray *rootArray = [NSMutableArray array];
    NSMutableArray *rAr = [NSMutableArray array];
    NSMutableArray *arr = [NSMutableArray array];
    
    
    NSString *str = @"http://a.xcar.com.cn/interface/6.0/getNewsList.php?limit=10&offset=0&type=1&ver=6.1.2";
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:str];
    NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30];
    NSError *error = nil;
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:&error];
    if (!error) {
        NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        NSDictionary *dic1 = [dic objectForKey:@"focusList"];
        NSArray *array = [dic1 objectForKey:@"focusImgs"];
        for (NSDictionary *dic2 in array) {
            NSString *str = [dic2 objectForKey:@"imgURL"];
            [rootArray addObject:str];
            NSString *link = [dic2 objectForKey:@"newsLink"];
            [rAr addObject:link];
            NSString *title = [dic2 objectForKey:@"title"];
            [arr addObject:title];
        }
    }
    
    [rAr addObject:arr];
    [rootArray addObject:rAr];

    return rootArray;
}
@end
